<?php

namespace App\Http\Controllers\AppApi\Common;

use App\Http\Controllers\AppApi\BaseController;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;

class UploadController extends BaseController
{
    public function file(Request $request)
    {
        $rule = [
            'image' => 'required'
        ];
        $this->validate($request, $rule);
        $files = $request->file('image');
        $data = [];
        foreach ($files as $item) {
            $path = Storage::disk('local')->putFile(date('Ymd'), $item);
            array_push($data, $path);
        }
        return $this->output($data);
    }
}